package com.training.food.controller;

import com.training.food.Domain.StatisticsDomain;
import com.training.food.Mapper.RetailMapper;
import com.training.food.Mapper.SlaughterMapper;
import com.training.food.Mapper.WSmarketMapper;
import com.training.food.util.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 统计信息的后端处理
 * 柱状图+饼状图
 */
@RestController
@RequestMapping("/statistics")
public class StatisticsController {
    @Autowired
    SlaughterMapper slaughterMapper;
    @Autowired
    RetailMapper retailMapper;
    @Autowired
    WSmarketMapper wSmarketMapper;
    /**
     * 柱状图计算交易的数量
     */
    @PostMapping("/zz")
    @Transactional
    public CommonResult zhuzhuangtu()
    {
        int[] res=new int[3];
        int s=slaughterMapper.get3num();
        int w=wSmarketMapper.get3num();
        int r=retailMapper.get3num();
        res[0]=s;
        res[1]=w;
        res[2]=r;
        return CommonResult.success(res);
    }
    @PostMapping("/bz")
    @Transactional
    public CommonResult bingzhuangtu(){
        List<StatisticsDomain> res=retailMapper.getttv();
        return CommonResult.success(res);
    }
}
